<?PHP

require 'connect.inc';
$key = $_REQUEST["key"];
$type = $_REQUEST["type"];
$ms = "";
if ($type == 1) {
    $result = mysql_query("SELECT * FROM USERS WHERE user_name = '$key'");
    if ($result && mysql_num_rows($result) > 0)
        $ms .= "* Username already exist.";
    else {
        $ms .= "* Username is available.";
    }
} else {
    $result = mysql_query("SELECT * FROM USERS WHERE email = '$key'");
    if ($result && mysql_num_rows($result) > 0)
        $ms .= "* Email already exist.";
    else {
    $ms .= "* Email is available.";    
    }
   
}
echo $ms;
?>